/***************************************************************************************************
  Copyright(C)   2011-9-5
  All rights reserved.
  File Name: clientservicethread.h

  Description:配置模块TCP服务端线程块
              线程块，主要调用服务端处理块clientservice来进行tcp所有处理


  ***************************************************************************************************/

#ifndef CLIENTSERVICETHREAD_H
#define CLIENTSERVICETHREAD_H

#include <QThread>

#include "clientservice.h"


class ClientServiceThread : public QThread
{
    Q_OBJECT
public:
    explicit ClientServiceThread(int socketID, int state = 0, QObject *parent = 0);
    ClientService *csv;

    ~ClientServiceThread();

protected:
    void run();

private:
    int serviceState;               //服务器状态
    int socketID;                   //连接到此服务端的客户端的ID

signals:
    //收到喂狗数据信号
    void receFreedData(const FreedDogStruct& freedDogStruct);

    //发送更新服务器信息
    void serviceInfoSignal(const QString& fileName, const int fileLen);

    //发送接收更新文件情况 0：开始更新 1：更新成功 -1:更新失敗
    void updateService(const int state, const int fileCount);

    //发送调试信息信号
    void sendDebugMsg(const QString& msg);

    //关闭服装此服务线程信号
    void delteService();

    //收到环境光度，服务端将光度数据发送到客户端
    void sendBrihgtness(const qint16 brightness);

    //配置已经进行更新，必须重新读取配置
    void updateConfig();

    void getLcdSetting();
    void receSetLcdIDListCmd(const QMap<qint16, qint8>& lcdState);

    //收到要改变LCD亮度信号
    void receChangeLcdBright(const qint16 brightness, const QList<quint16>& panelIDList);

//    void receSetLcdSettingsCmd(const LcdSettingStruct& lcdSettings);

    void receGetLcdStatus();                                               //申请获得LCD的状态

    void sendSetLcdSettingStatus(const qint8 state);
    void sendSetLcdTraValueStatus(const qint8 state);

    void receLcdBackLightCtl(const qint8 cmd, const QList<quint16>& panelIDList);
    void receQueryVideoStatus(const qint16 cmd);

    void receSlcdCollectState(const QList<PanelInfoStruct>& infoList);

    void sendLcdSetting(const LcdSettingStruct& lcdSettings);

    void sendBackLightStatus(qint8 status);
    void sendVideoStatus(const QList<LCDSTATUS>& status, const bool isSendToTis);

    void serviceClose();

    void receChangeBriLv(const LcdSettingStruct& settingStruct);            //收到改变LCD 亮度等级信息
    void receSystemState(const SystemState& state);

    void receCheckLcdCmd(const qint8 cmd);      //收到检测LCD屏的命令

    //lcd回复状态,包括亮度设置和背景灯设置这２个设置
    void lcdAnswerStatus(QList<LCDSTATUS> status);

};

#endif // CLIENTSERVICETHREAD_H
